import 'package:flutter/material.dart';
import 'package:full_display/common/qxp_color.dart';
import 'package:full_display/common/qxp_style.dart';
import 'package:full_display/generated/l10n.dart';
import 'package:full_display/provide/bluetooth_provider.dart';
import 'package:full_display/unit/screen/screen_utility.dart';
import 'package:provider/provider.dart';

class BluetoothSettingDialog extends StatefulWidget {
  final String bluetoothName;
  VoidCallback cancelBtnTap;
  VoidCallback okBtnTap;
  TextEditingController vc;
  BluetoothSettingDialog(
      {this.bluetoothName = '',
      required this.cancelBtnTap,
      required this.okBtnTap,
      required this.vc});
  late BluetoothProvider bluetoothData;

  @override
  State<BluetoothSettingDialog> createState() => _WifiSettingDialogState();
}

class _WifiSettingDialogState extends State<BluetoothSettingDialog> {
  @override
  Widget build(BuildContext context) {
    widget.bluetoothData = context.watch<BluetoothProvider>();
    return Container(
      width: 320.0.W,
      height: 232.0.W,
      decoration: const BoxDecoration(
        gradient: LinearGradient(
            //渐变位置
            begin: Alignment.topCenter, //右上
            end: Alignment.bottomCenter, //左下
            //渐变颜色[始点颜色, 结束颜色]
            colors: [ColorPlate.app_blue, ColorPlate.sub_blue]),
        borderRadius: BorderRadius.all(Radius.circular(8.0)),
      ),
      child: Container(
        child: Column(
          children: [
            Container(
              padding: EdgeInsets.only(left: 24.0.W, right: 24.0.W),
              child: Column(
                children: [
                  Container(
                    padding: EdgeInsets.only(top: 20.0.W),
                    child: Text(
                      S.of(context).lanyashezhi,
                      style: StandardTextStyle.textWhite17Style,
                    ),
                  ),
                  Container(
                    padding: EdgeInsets.only(top: 42.0.W),
                    child: Stack(
                      children: [
                        Positioned(
                          top: 12,
                          child: Text(
                            S.of(context).lanyamingcheng,
                            style: StandardTextStyle.textWhite17Style,
                          ),
                        ),
                        Container(
                          padding: EdgeInsets.fromLTRB(90, 0, 0, 0),
                          height: 50.0.W,
                          child: TextField(
                              style: const TextStyle(color: Colors.white),
                              controller: widget.vc,
                              decoration: const InputDecoration(
                                enabledBorder: UnderlineInputBorder(
                                  borderSide: BorderSide(color: Colors.blue),
                                ),
                                focusedBorder: UnderlineInputBorder(
                                  borderSide: BorderSide(color: Colors.blue),
                                ),
                              ),
                              autofocus: true,
                              cursorColor: ColorPlate.white),
                        ),
                      ],
                    ),
                  ),
                  const Divider(
                    height: 1.0,
                    color: ColorPlate.white, // 分割线颜色
                  ),
                ],
              ),
            ),
            Container(
              padding: EdgeInsets.only(top: 40.0.W),
              child: Divider(
                height: 1.0.W,
                color: ColorPlate.white, // 分割线颜色
              ),
            ),
            Container(
              height: 50.0.W,
              child: Row(
                children: [
                  Expanded(
                    child: InkWell(
                      onTap: () {
                        widget.vc.text = '';
                        Navigator.pop(context);
                      },
                      child: Center(
                        child: Text(
                          S.of(context).quxiao,
                          style: StandardTextStyle.textWhite16Style,
                        ),
                      ),
                    ),
                  ),
                  Container(
                    width: 0.5.W,
                    height: 50.0.W,
                    color: ColorPlate.white,
                  ),
                  Expanded(
                    child: InkWell(
                      onTap: () {
                        widget.okBtnTap();
                        Navigator.pop(context);
                      },
                      child: Center(
                        child: Text(
                          S.of(context).queding,
                          style: StandardTextStyle.textWhite16Style,
                          textAlign: TextAlign.center,
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
